package com.penngo.yiiboot.web;

import com.aventstack.extentreports.testng.listener.ExtentIReporterSuiteClassListenerAdapter;
import com.penngo.yiiboot.base.BaseChromeTest;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

import java.time.Duration;

@Listeners(ExtentIReporterSuiteClassListenerAdapter.class)
public class LoginTest  extends BaseChromeTest {

    /**
     * 首页
     */
    @Test(description="登录()")
    public void testLogin(){
        System.out.println("testLogin===============");
        driver.get(url + "?r=site/index");
        driver.findElement(By.cssSelector("#username")).sendKeys("admin");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#login_btn")).click();


//        driver.findElement(By.cssSelector(".box-title")).

        boolean b = new WebDriverWait(driver, Duration.ofSeconds(3))
        .until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.cssSelector(".box-title")), "系统信息"));
        Assert.assertTrue(b, "登录成功");
        //sleep(10);
    }
}
